package com.marktotop;

import com.alibaba.druid.pool.DruidDataSource;
import com.marktotop.config.SpringConfig;
import com.marktotop.dao.BookDao;
import com.marktotop.dao.UserDao;
import com.marktotop.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


/**
 * @author WXLD
 * @data 2021/4/18 - 21:46
 */
public class Main {

    public static void main(String[] args) {
        /* 使用 SpringConfig 注解配置类替换 SpringContext.xml 文件 */
        ApplicationContext context = new AnnotationConfigApplicationContext(SpringConfig.class);
//        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//        UserService userService = (UserService) context.getBean("userService");
//        userService.save();
//
//        UserDao userDao = (UserDao) context.getBean("userDao");
//        userDao.save();
//
//        BookDao bookDao = (BookDao) context.getBean("bookDao");
//        bookDao.save();

        /*使用注解方式加载第三方资源 Druid */
//        DruidDataSource dataSource = (DruidDataSource) context.getBean("dataSource");
//        System.out.println(dataSource);
    }
}
